package io.renren.modules.sys.service.impl;

import io.renren.common.utils.Constant;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.FyClassScheduleDao;
import io.renren.modules.sys.entity.FyClassScheduleEntity;
import io.renren.modules.sys.service.FyClassScheduleService;


@Service("fyClassScheduleService")
public class FyClassScheduleServiceImpl extends ServiceImpl<FyClassScheduleDao, FyClassScheduleEntity> implements FyClassScheduleService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String classid = (String)params.get("classid");

        IPage<FyClassScheduleEntity> page = null;
        if(StringUtils.isNotBlank(classid)){
            page = this.page(
                    new Query<FyClassScheduleEntity>().getPage(params),
                    new QueryWrapper<FyClassScheduleEntity>().eq(StringUtils.isNotBlank(classid),"class_id",Integer.parseInt(classid))
                            .apply(params.get(Constant.SQL_FILTER) != null, (String)params.get(Constant.SQL_FILTER))
            );
        }else{
            page = this.page(
                    new Query<FyClassScheduleEntity>().getPage(params),
                    new QueryWrapper<FyClassScheduleEntity>()
            );
        }


        return new PageUtils(page);
    }

}
